package org.thomias.exo1.filereader;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Main {

	public static void main(String[] args) {
		try {
			File file = new File("img.jpg");
			FileInputStream inFile = null;
			FileOutputStream outFile = null;
			try {
				inFile = new FileInputStream(file);
				outFile = new FileOutputStream("new_" + file.getName());
				byte[] b = new byte[1024 * 1024];
				System.out.println("Start copy of " + file.getName() + "...");
				while (inFile.read(b) != -1) {
					outFile.write(b);
					// System.out.println(new String(b) + "|");
				}
			} finally {
				if (outFile != null) {
					outFile.close();
				}
				if (inFile != null) {
					inFile.close();
				}
			}
			System.out.println("End process");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
